<?php
namespace Home\Controller;
use Think\Controller;
// 开发者：杨晓杰，
// 邮箱：2902468225@qq.com 


class CommonController extends Controller {
	// 搜索功能，根据搜索类别跳到不同搜索结果
	public function search(){
		$type=I('get.type');//0学生，1企业，2资讯，3竞赛搜索
		switch ($type) {
			case 0:
				R('User/listPage');
				break;
			case 1:
				R('Cpn/listPage');
				break;
			case 2:
				R('News/listPage');
				break;
			case 3:
				R('competition/searchList');
			break;
			default:
				R('User/listPage');
				break;
		}
	}
	// 热门搜索
	public function hotSearch(){
		$data=M('hot_search')->order('times desc')->limit(10)->select();
		echo json_encode($data);
	}
	// 根据输入匹配热门搜索
	public function checkHot(){
		$key=I('get.key');
        $where['name']=array('like',"%".$key."%");
        $data=M('hot_search')->where($where)->order('times desc')->limit(10)->select();
        echo json_encode($data);
	}
	public function schoolSearch(){
		$where['name']=array('like',"%".I('get.key')."%");
		$data['list']=M('school')->where($where)->order('hot desc')->limit(10)->select();
		// $data['list'][0]['name']=I('get.key');
		echo json_encode($data);
	}
	// 地区
	public function area(){
		$where['city']=array('like','%'.I('get.key').'%');
		$data=M('area')->where($where)->order('hot desc')->limit(10)->select();
		echo json_encode($data);
	}
}